<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>各院系按性别统计人数</title>

    <!--表格-->
    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }

        .el-header{
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: left;
            line-height: 50px;
        }

        .el-footer{
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;

        }

    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header><div>各院系按性别统计人数</div></el-header>
        <el-main>

            <!--表格-->
            <template>
                <el-table
                        :data="tableData"
                        style="width: 100%"
                        :row-class-name="tableRowClassName"
                        @selection-change="handleSelectionChange">
                    <el-table-column
                            type="index">
                    </el-table-column>
                    <el-table-column
                            prop="name"
                            label="院系名称"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="sex"
                            label="性别"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="sum"
                            label="人数"
                            align="center">
                    </el-table-column>
                </el-table>
            </template>

        </el-main>
        <el-footer>各院系按性别统计人数</el-footer>
    </el-container>



</div>

<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script src="js/axios-0.18.0.js"></script>

<script>
    new Vue({
        el: "#app",

        mounted() {
            this.selectAll();

        },

        methods: {

            //----------------分页查询数据---------------
            selectAll() {

                var _this = this;

                axios({
                    method: "post",
                    url: "http://localhost:8080/teaching/depart/demo",
                    data: _this.sexcount
                }).then(function (resp) {
                    _this.tableData = resp.data;
                    /*  _this.totalCount = resp.data.totalCount;*/
                    console.log(resp);
                    console.log(_this.tableData);
                })
            },



            tableRowClassName({row, rowIndex}) {
                if (rowIndex === 1) {
                    return 'warning-row';
                } else if (rowIndex === 3) {
                    return 'success-row';
                }
                return '';
            },



            //退出系统
            exit(){
                window.open('http://localhost:8080/bookstore/login.jsp','_blank')
            },

            //刷新
            openFullScreen() {
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                setTimeout(() => {
                    loading.close();
                    location.reload();
                }, 1000);
            }
        },

        data() {
            return {


                //书籍的数据
                sexCount: {
                    name: '',
                    sex: '',
                    sum: '',
                },


                //表格数据
                tableData: [{
                    name: '土木',
                    sex: '男',
                    sum: '1',
                }, {
                    name: '土木',
                    sex: '男',
                    sum: '1',
                }, {
                    name: '土木',
                    sex: '男',
                    sum: '1',
                }, {
                    name: '土木',
                    sex: '男',
                    sum: '1',
                }]
            }
        }
    })


</script>

</body>
</html>